<?php
 if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Class Content extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
        //$this->checkAdmin($this->session->userdata('admin_id'));
        $this->data['controller'] = 'content';         
        $this->load->model('Mcontent');
    }
    
//    
//    public function getQrcode(){
//        //Get parameters
//        $idCoupon= $this->getParamInt("idcoupon");
//        $idUser= $this->getParamInt("iduser");
//        $lengthCode=6;
//        //Create coupon qrcode
//        $qrCode=$this->Mcontent->genQrcode($lengthCode);
//        //Save qrcode and user 
//        $result=$this->Mcontent->saveQrcode($qrCode,$idUser,$idCoupon);
//        //send api
//        die(json_encode($result)); 
//    }
    public function getnewincentive()
    {
        $page  =  $this->getParamInt("page");
        $limit =  $this->getParamInt("limit");
        $zone  =  $this->getParamInt("zone");
//        $province_id = $this->getParamString("province_id");
//        $is_partner = $this->getParamInt("is_partner");
        die(json_encode($this->Mcontent->getNewIncentive($page,$limit,$zone)));
    }
    
    public function getIncentiveRes()
    {
        $page  =  $this->getParamInt("page");
        $limit =  $this->getParamInt("limit");
        $zone  =  $this->getParamInt("zone");
        $id_res=  $this->getParamInt("restaurant_id");
        die(json_encode($this->Mcontent->getIncentiveResDb($page,$limit,$zone,$id_res)));
    }
    
    public function getincentivefixed()
    {
        $limit = $this->getParamInt("limit");
        $stt = $this->getParamInt("stt");
        die(json_encode($this->Mcontent->getIncentiveFixed($limit,$stt)));
    }
    
    public function getincentivemonthly()
    {
        $limit = $this->getParamInt("limit");
        $stt = $this->getParamInt("stt");
        die(json_encode($this->Mcontent->getIncentiveMonthly($limit,$stt)));
    }
    
    public function getrestaurantmenus()
    {
        $id = $this->getParamInt("id");
        die(json_encode($this->Mcontent->getRestaurantMenus($id)));
    }
    
    public function getreviewrestaurant(){
        $id = $this->getParamInt("id");
        $page = $this->getParamInt("page");
        $limit = $this->getParamInt("limit");
        die(json_encode($this->Mcontent->getReviewRestaurant($id,$page,$limit)));
    }
    	
    public function submitreviewrestaurant(){
        $restaurant_id = $this->getParamInt("restaurant_id");
        $user_id = $this->getParamInt("user_id");
        $name = $this->getParamString("name");
        $star = $this->getParamInt("star");
        $content = $this->getParamString("content");
        die(json_encode($this->Mcontent->submitReviewRestaurant($restaurant_id,$user_id,$name,$star,$content)));
    }
    
	public function getreviewcoupon(){
            $id = $this->getParamInt("id");
            $limit = $this->getParamInt("limit");
            $page = $this->getParamInt("page");
            die(json_encode($this->Mcontent->getReviewCoupon($id,$page,$limit)));
	}
	
	
	public function submitreviewcoupon(){
        $coupon_id = $this->getParamInt("coupon_id");
        $user_id = $this->getParamInt("user_id");
        $name = $this->getParamString("name");
        $star = $this->getParamInt("star");
        $content = $this->getParamString("content");
        die(json_encode($this->Mcontent->submitReviewCoupon($coupon_id,$user_id,$name,$star,$content)));
    }
	
	public function submitbooking(){
		$user_id = $this->getParamInt('user_id');
		$phone = $this->getParamString("phone");
                $date = $this->getParamString("date");
                $time = $this->getParamString("time");
                $email= $this->getParamString("email");
                $name= $this->getParamString("name");
		$address_id = $this->getParamInt('address_id');
                $required = $this->getParamString('required');
                $peoples= $this->getParamString('peoples');
                die(json_encode($this->Mcontent->submitBooking($user_id,$phone,$date,$time,$address_id,$email,$name,$required,$peoples)));
	}
	
	public function getincentivelabel(){
        $limit = $this->getParamInt("limit");
        $stt = $this->getParamInt("stt");
        $label = $this->getParamInt("label");
        die(json_encode($this->Mcontent->getIncentiveLabel($limit,$stt,$label)));
    }
    
    public function ratinglabel(){
        $label = $this->getParamInt("label");
        die(json_encode($this->Mcontent->getRatingLabel($label)));
    }
	
    public function countdownapp(){
            $device_name = $this->getParamString('device_name');
            $os_name = $this->getParamString('os_name');
            die(json_encode($this->Mcontent->countDownApp($device_name,$os_name)));
    }
	
}
